home *** CD-ROM | disk | FTP | other *** search
/ Shareworld 5 / Shareworld 5 (Disk 1 of 2).adf / OpenWindow / OpenWindow.Example1 next >
Text File  |  1995-08-29  |  3KB  |  95 lines

  1.     ;Open window, public domain
  2.     ;Published with Share-world 5
  3.  
  4.     ;-- Exec --
  5. Openlib        = -552
  6. Closelib    = -414
  7.  
  8.     ;-- Intuition --
  9. Openwindow    =    -204    
  10. Closewindow    =    -72
  11.  
  12.     ;Program
  13. Start
  14.     move.l 4,a6    ;Get exec lib base
  15.     move.l #iname,a1    ;library name
  16.     move.l #0,d0    ;any version
  17.     jsr Openlib(a6)    ;open
  18.     cmp.l #0,d0    ;d0 will be zero if lib no open
  19.     beq error    ;check for error, if error go to error
  20.     move.l d0,ibase    ;store base
  21.     move.l ibase,a6    ;could change to move.l d0,a6
  22.  
  23.     move.l #Window,a0    ;a0 now holds a pointer to the Window 
  24.                 ;Definition Table
  25.     jsr Openwindow(a6)
  26.  
  27.     cmp.l #0,d0    ;D0 will be zero if the window has failed to open
  28.     beq error    ;Did it open?
  29.     move.l d0,windowhd    ;Store that handle
  30.  
  31.     bsr delay    ;Branch to the delay subroutine
  32.             ;Delays can also be created by using any of 
  33.             ;Auckland's public transport
  34.  
  35. error
  36.     move.l ibase,a6        ;It's that ibase character again!
  37.                 ;Note that if ibase wasn't opened then a6 will
  38.                 ;hold a zero, this will cause an error when 
  39.                 ;we try to close the window (because we don't
  40.                 ;have the correct base pointer).  This is
  41.                 ;okay because if the library wasn't opened
  42.                 ;then the window wouldn't of opened either
  43.                 ;Clever eh! 
  44.     move.l windowhd,a0    ;Get handle of window (so computer nos what
  45.                 ;window to close)
  46.     cmp.l #0,a0        ;did the window open in first place?
  47.                 ;(windowhd zero if it didn't)
  48.     beq nowindow        ;don't close if zero
  49.     jsr Closewindow(a6)    ;Closing due to renovations
  50. nowindow
  51.  
  52.     move.l 4,a6    ;get exec base
  53.             ;Note:You should close the libraries last.
  54.     move.l ibase,a1    ;library base for closing
  55.     cmp.l #0,a1    ;did library open
  56.     beq noi
  57.     jsr Closelib(a6)    ;Let's close this thing once and for all
  58. noi
  59.     moveq #0,d0    ;Extra bit not mention in article, tell Cli no 
  60.             ;error, 0 okay, 20 failure
  61.     rts        ;exit to CLI, or assembler
  62. delay
  63.     move.l #0,d0        ;clear d0 (start counting from zero)
  64. dl1
  65.     add.l #1,d0    
  66.     cmp.l #3000000,d0    ;lasts for about 4-5 secs of my A1200
  67.     bne dl1            ;Are we there yet?
  68.     rts            ;Yes!
  69.     
  70.     ;variables
  71. ibase    dc.l 0            ;storage for ibase
  72. windowhd    dc.l 0        ;storage for window's handle
  73.     
  74.     ;Window Definition
  75. Window
  76.     dc.w 10,30    ;x-y position
  77.     dc.w 200,200    ;width-height
  78.     dc.b 1,2    ;colours
  79.     dc.l $200    ;'flags' for messages (next issue!)
  80.     dc.l $100f    ;'flags' for appareance (next issue!!)
  81.             ;Change to $1800 for no border!
  82.     dc.l 0,0    ;gadgets, checkmark
  83.     dc.l WinName    ;pointer to window name
  84.     dc.l 0        ;screen pointer (don't matter/using workbench)
  85.     dc.l 0         ;No bitmap (for fancy windows only!)
  86.     dc.w 100,100    ;smallest width-height
  87.     dc.w 600,250    ;largest width-height
  88.     dc.w 1        ;workbench window
  89.  
  90.     ;strings
  91. iname    dc.b 'intuition.library',0
  92. WinName
  93.     dc.b 'My Window likes Led Zep',0    ;Do you?
  94.     
  95.